<?php
/**
 * @description : get content of a xml file.
 * @class-name  : ConfigContent. 
 * @method      : get().
 * @method      : instance().
 * @author      : stephen.mo@hotmail.com
 * @version     : $Id , 1.0.0
 * @date        : Mar 24,2011
 */

class ConfigContent {

    const CONST_TYPE_OBJ = 'Object';
    const CONST_TYPE_ARR = 'Array';
    static private $instance;
    private $config;
    
    /** construct of class */
    public function __construct($file_path) {
        $this->config = ConfigReaderFactory::getInstance()->getConfigReader($file_path)->getConfig();
    }
    
    /** instance of class */
    static public function getInstance($file_name) {/*{{{*/
        if (!isset(self::$instance)) {
            $class = __CLASS__;
            self::$instance = new $class($file_name);
        }
        return self::$instance;
    }/*}}}*/
    

    /**
     * @description : get the content of xml file
     * @paramter    : (tring)$type - witch type will you need to return.
     * @author      : stephen.mo <stephen.mo@hotmail.com>
     * @date        : Mar 24,2011
     */
    public function get($type=self::CONST_TYPE_OBJ) {/*{{{*/
        if (empty($this->config)) return FALSE;
        $ret = array();
        if ($type == self::CONST_TYPE_ARR) {
            foreach($this->config as $key=>$val) {
                $ret[$key] = (array)$val;
            }
            $this->config = $ret;
        }
        return $this->config;

    }/*}}}*/




}

?>
